import 'package:flutter/material.dart';
import 'package:mxapp/custom/GoodsList.dart';
import 'package:mxapp/utils/global.dart';
import '../main.dart';
import 'MyDemo01.dart';

class NavigationBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(          // Add the 3 lines from here...
        primaryColor: themeColor,
      ),
      debugShowCheckedModeBanner: false,
      home: NavigationBar(),
    );
  }
}

class NavigationBar extends StatefulWidget {
  @override
  _NavigationBarState createState() => _NavigationBarState();
}

class _NavigationBarState extends State<NavigationBar> {
  int _page = 0;

  List<Widget> list = [
    GoodsList(),
    MyDemo01(),
    MyApp(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: list[_page],
      bottomNavigationBar: BottomNavigationBar(
        elevation: 4,
        selectedFontSize: 12,
        currentIndex: _page,
          type: BottomNavigationBarType.fixed,
          items:[
            BottomNavigationBarItem(
                icon: Icon(Icons.home),
                title: Text("首页")
            ),
            BottomNavigationBarItem(
                icon: Icon(Icons.category),
                title: Text("分类")
            ),
            BottomNavigationBarItem(
                icon: Icon(Icons.person),
                title: Text("我的")
            )
          ],
        onTap: (int index){
          setState(() {
            _page = index;
          });
        },
      ),
    );
  }
}
